﻿using parkMonitor.model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace parkMonitor.language {
	public class LngBind : Binding {
		public LngBind() {
			//Source = App.Current.FindResource("lng");
			Source = Language.ins;
		}

		public LngBind(string path)
			: base(path) {
			//Source = App.Current.FindResource("lng");
			Source = Language.ins;
		}
	}

	public enum LangType {
		zh_cn = 1,
		en_us = 2
	}

	public class Language : INotifyPropertyChanged {
		public static Language ins = new Language();

		public LangType lngType = LangType.zh_cn;

		Dictionary<string, string> mapLng = new Dictionary<string, string>();

		string[] lng = new string[0];

		public Language() {
			//		key				zh-cn					eu-us
			lng = new string[] {
				"autoPackSys"	, "智能泊车系统", "Intelligent Pack System"	,

				"central"		, "中控"		, "Central"					,
				"centralPort"	, "中控端"		, "Central"                 ,
				"webServer"		, "Web服务器"	, "Web Server"				,
				"plc"			, "PLC"			, "PLC"						,
				"numMachinePort", "号牌机端"	, "Num Plate Machine"		,
				"numMachine"	, "号牌机"		, "Num Plate Machine"		,
				"measurePort"	, "测量端"		, "measuring"				,
				"laser"			, "激光"		, "Laser"					,
				"trayPort"		, "托盘端"		, "Tray"					,
				"tray"			, "托盘"		, "Tray"					,
				"robotPort"		, "机械手端"    , "Robot"					,
				"robot"			, "机械手"		, "Robot"					,
				"robotTongs"	, "机械手"		, "Robot"					,
				"raster"		, "光栅"		, "Raster"					,
				"ultrasonic"	, "超声波"		, "Ultrasonic"				,
				"sensor"		, "传感器"		, "Sensor"                  ,
				"garage"		, "车库"		, "Central"					,
				"car"			, "车辆"		, "Car"						,
				"carObject"		, "车辆物体"	, "Car"						,
				"ortherObject"	, "其他物体"	, "Orther Object"			,

				"cpu"			, "CPU"			, "CPU"						,
				"mem"			, "内存"		, "Mem"                     ,
				"hostNmae"		, "主机名"		, "Host Name"				,
				"gpu"			, "显卡"		, "GPU"				        ,
				"os"			, "操作系统"	, "OS"					    ,
				"version"		, "版本"		, "Version"                 ,

				"mainPanel"		, "主界面"		, "Main Panel"				,
				"name"			, "名称"		, "Name"                    ,
				"info"			, "信息"		, "Info"					,
				"detail"		, "详细信息"	, "Details"					,
				"alarmInfo"		, "报警信息"	, "Alarm Info"				,
				"serNum"		, "编号"		, "SN"						,
				"log"			, "日志"		, "Log"                     ,
				"ok"			, "确定"		, "Ok"						,
				"cancel"		, "取消"		, "Cancel"                  ,
				"sureExit"		, "确定退出？"	, "Sure Exit?"              ,
				"devInfo"       , "设备信息"    , "Device Info"             ,
				"devList"       , "设备列表"    , "Device List"             ,
				"devName"       , "设备名"		, "Device Name"             ,
				"reset"			, "复位"		, "Reset"					,
				"write"			, "写入"		, "Write"                   ,

				"file"			, "文件"		, "File"                    ,
				"open"			, "打开"		, "Open"                    ,
				"close"			, "关闭"		, "Close"                   ,
				"import"		, "导入"		, "Import"                  ,
				"exit"			, "退出"		, "Exit"					,

				"noDev"			, "无设备"		, "No Device"				,
				"run"			, "启动"		, "Run"                     ,
				"all"			, "全部"		, "All"                     ,
				"transferSys"	, "转运系统"	, "Transfer Sys"			,
				"laserRadar"	, "激光雷达"    , "Laser & Radar"           ,
				"robotHand"		, "机械手"		, "Robot Hand"				,
				"measureSys"	, "测量系统"    , "Measure Sys"				,
                "restartProcess", "重启上次流程", "restart last process"    ,

				"view"			, "视图"		, "View"                    ,
				"carView"       , "车位视图"    , "Car View"                ,
				"robotView"     , "机械手"    , "Robot View"				,

				"alarm"			, "预警"		, "Alarm"                   ,

				"check"			, "检查"		, "Check"                   ,

				"help"			, "帮助"		, "Help"                    ,
				"sysInfo"		, "系统信息"	, "Sys Info"                ,
				"helpDoc"		, "使用帮助"	, "Help Doc"                ,
				"aboutUs"		, "关于我们"	, "About Us"                ,

				"cmd"			, "命令"		, "Command"                 ,
				"startClient"   , "启动客户端"  , "Start Client"            ,
				"startServer"   , "启动服务器"  , "Start Server"            ,
				"server"		, "服务器"		, "Server"					,
				"client"		, "客户端"		, "Client"					,

				"offline"		, "离线"		, "Offline"					,
				"normal"		, "正常"		, "Normal"                  ,
				"canReset"		, "可复位"		, "Can Reset"               ,
				"warning"		, "警告"		, "Warn"					,
				"error"			, "错误"		, "Error"					,
				"aFrew"			, "个"			, " "						,
				"connect"		, "连接"        , "Connect"                 ,
				"disconnect"    , "断开"        , "Disconnect"              ,
				"search"		, "搜索"        , "Search"					,
			};

			//mapLng = new Dictionary<string, string>() {
			//	{ "central", "中控" },
			//	{ "garage", "车库" }
			//};

			int splitSize = 3;
			//int zhIdx = 1;
			//int enIdx = 2;
			int keyIdx = 0;
			int lngIdx = (int)lngType;
			for(int i = 0; i < lng.Length; i += splitSize) {
				mapLng[lng[i + keyIdx]] = lng[i + lngIdx];
			}

			mapLng["aboutWinText"] = @"智能泊车系统 中控端

武汉大学

CopyRight(C) 2013 - 2018
保留所有权利";

		}

		//public void swithLanguage(string lngName) {

		//}

		public string autoPackSys { get { return mapLng["autoPackSys"]; } }
		public string central { get { return mapLng["central"]; } }
		public string centralPort { get { return mapLng["centralPort"]; } }
		public string webServer { get { return mapLng["webServer"]; } }
		public string plc { get { return mapLng["plc"]; } }
		public string numMachinePort { get { return mapLng["numMachinePort"]; } }
		public string numMachine { get { return mapLng["numMachine"]; } }
		public string measurePort { get { return mapLng["measurePort"]; } }
		public string laser { get { return mapLng["laser"]; } }
		public string trayPort { get { return mapLng["trayPort"]; } }
		public string tray { get { return mapLng["tray"]; } }
		public string robotPort { get { return mapLng["robotPort"]; } }
		public string robot { get { return mapLng["robot"]; } }
		public string robotTongs { get { return mapLng["robotTongs"]; } }
		public string raster { get { return mapLng["raster"]; } }
		public string ultrasonic { get { return mapLng["ultrasonic"]; } }
		public string sensor { get { return mapLng["sensor"]; } }
		public string garage { get { return mapLng["garage"]; } }
		public string car { get { return mapLng["car"]; } }
		public string carObject { get { return mapLng["carObject"]; } }
		public string ortherObject { get { return mapLng["ortherObject"]; } }

		public string cpu { get { return mapLng["cpu"]; } }
		public string mem { get { return mapLng["mem"]; } }
		public string hostNmae { get { return mapLng["hostNmae"]; } }
		public string gpu { get { return mapLng["gpu"]; } }
		public string os { get { return mapLng["os"]; } }
		public string version { get { return mapLng["version"]; } }

		public string mainPanel { get { return mapLng["mainPanel"]; } }
		public string name { get { return mapLng["name"]; } }
		public string info { get { return mapLng["info"]; } }
		public string detail { get { return mapLng["detail"]; } }
		public string alarmInfo { get { return mapLng["alarmInfo"]; } }
		public string serNum { get { return mapLng["serNum"]; } }
		public string log { get { return mapLng["log"]; } }
		public string ok { get { return mapLng["ok"]; } }
		public string cancel { get { return mapLng["cancel"]; } }
		public string sureExit { get { return mapLng["sureExit"]; } }
		public string devInfo { get { return mapLng["devInfo"]; } }
		public string devList { get { return mapLng["devList"]; } }
		public string devName { get { return mapLng["devName"]; } }
		public string reset { get { return mapLng["reset"]; } }
		public string write { get { return mapLng["write"]; } }

		public string file { get { return mapLng["file"]; } }
		public string open { get { return mapLng["open"]; } }
		public string close { get { return mapLng["close"]; } }
		public string import { get { return mapLng["import"]; } }
		public string exit { get { return mapLng["exit"]; } }

		public string noDev { get { return mapLng["noDev"]; } }
		public string run { get { return mapLng["run"]; } }
		public string all { get { return mapLng["all"]; } }
		public string transferSys { get { return mapLng["transferSys"]; } }
		public string laserRadar { get { return mapLng["laserRadar"]; } }
		public string robotHand { get { return mapLng["robotHand"]; } }
		public string measureSys { get { return mapLng["measureSys"]; } }
        public string restartProcess { get { return mapLng["restartProcess"]; } }

        public string view { get { return mapLng["view"]; } }
		public string carView { get { return mapLng["carView"]; } }

		public string alarm { get { return mapLng["alarm"]; } }

		public string check { get { return mapLng["check"]; } }

		public string help { get { return mapLng["help"]; } }
		public string sysInfo { get { return mapLng["sysInfo"]; } }
		public string helpDoc { get { return mapLng["helpDoc"]; } }
		public string aboutUs { get { return mapLng["aboutUs"]; } }

		public string cmd { get { return mapLng["cmd"]; } }
		public string startClient { get { return mapLng["startClient"]; } }
		public string startServer { get { return mapLng["startServer"]; } }
		public string server { get { return mapLng["server"]; } }
		public string client { get { return mapLng["client"]; } }

		public string offline { get { return mapLng["offline"]; } }
		public string normal { get { return mapLng["normal"]; } }
		public string canReset { get { return mapLng["canReset"]; } }
		public string warning { get { return mapLng["warning"]; } }
		public string error { get { return mapLng["error"]; } }
		public string aFrew { get { return mapLng["aFrew"]; } }
		public string connect { get { return mapLng["connect"]; } }
		public string disconnect { get { return mapLng["disconnect"]; } }
		public string search { get { return mapLng["search"]; } }

		public string aboutWinText { get { return mapLng["aboutWinText"]; } }

		public virtual event PropertyChangedEventHandler PropertyChanged;
		public virtual void FirePropertyChanged(string propertyName) {
			if(PropertyChanged != null) {
				PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
